package cn.bdqn.utils;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class RedisUtil {
    @Resource
    RedisTemplate redisTemplate;

    /**
     * 取值
     * @param key
     * @param result
     * @return
     */
    public Object get(String key){
        ValueOperations<String,Object> valueOperations = redisTemplate.opsForValue();
        Object result = valueOperations.get(key);
        return result;
    }


    /**
     * 赋值
     * @param key
     * @param value
     */
    public void set(String key,Object value){
        ValueOperations<String,Object> valueOperations = redisTemplate.opsForValue();
        valueOperations.set(key,value);
    }
}
